﻿using System;
using System.Reflection;
namespace A2Z.DataObjects
{
    // clone class
    public static class Cloner
    {
        /// <summary>
        /// This method will copy the content of each property to the destination object.
        /// Both arguments should have the same type and cannot be null.
        /// </summary>
        /// <param name="Source"></param>
        /// <param name="Destination"></param>
        public static void Clone(object source, object destination)
        {

            PropertyInfo[] fromFields = null;
            PropertyInfo[] toFields = null;

            fromFields = source.GetType().GetProperties();
            toFields = destination.GetType().GetProperties();

            PropertyHandler.SetProperties(fromFields, toFields, source, destination);
        }
    }
}